<!DOCTYPE html>
<html>
<head>
    <title>${reportName}</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <script type="text/javascript">
        var path = window.document.location.href;
        var pathName = window.document.location.pathname;
        var hostPath = path.substring(0, path.indexOf(pathName));
        var projectName = pathName.substring(0, pathName.substr(1).indexOf("/") + 1);
        document.write('<scr' + 'ipt src="' + projectName + '/js/html/header.js"></scr'+'ipt>');
    </script>
</head>
<body>
<table id="dg" style="width:auto;height:auto">
    <thead>
        <tr>
            <#list columnMap?keys as key>
                <th field=${key} width="100" align="right"> ${columnMap['${key}']} </th>
            </#list>
        </tr>
    </thead>
</table>
<div id="dg-buttons" style="height:auto">
    <div>
        <span>&nbsp;&nbsp;&nbsp;&nbsp;选择:</span>
        <input type="text" id="searchKey" name="searchKey" class="easyui-combobox" value=""/>
        <span>等于:</span>
        <input type="text" id="searchValue" name="searchValue" class="easyui-validatebox" />
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" onclick="dgop.find()">查询</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-undo" onclick="dgop.clear()">清除</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-print',plain:true" 	onclick="dlgExport()">导出</a>
    </div>
</div>
<script>
    var initd = {
        queryDataURL:"/template/report/query?reportno=${reportNo}",//查询URL
        dataDicList:${dataDicList},
        dg:$('#dg')
    };

    initd.dg.datagrid({
        url: projectName + initd.queryDataURL,
        method: 'post',
        iconCls: 'icon-search',
        striped: true,
        nowrap: true,
        border: true,
        idField: 'id',
        singleSelect: true,
        rownumbers: true,
        fit: false,
        fitColumns: true,
        loadMsg: '数据加载中……',
        toolbar: '#dg-buttons',
        onClickRow: initd.onClickRow,
        pagination: true,
        pageNumber: 1,
        pageList: [10, 20, 50, 100],
        pageSize: initd.pageSize,
        queryParams: queryParams,
        loadFilter: amsDataFilter,
        loader: function(param, success, error) {
            $.ajax({
                type: "POST",
                url: projectName + initd.queryDataURL,
                data: JSON.stringify(param),
                dataType: "json",
                contentType : "application/json;charset=utf-8",
                success: function(data) {
                    $.messager.progress("close");
                    if (!data.success) {
                        $.messager.alert("错误提示", '[' + data.code + ']' + data.message);
                        return;
                    }
                    console.log(data)
                    success(data);
                },
                error: function (err, status) {
                    $.messager.progress("close");
                    $.messager.alert("错误提示", '[' + err.status + ']' + err.responseText);
                    initd.dg.datagrid('loaded');
                }
            });
        },
        onLoadSuccess: function (data) {
            $.messager.progress("close");
            rememberQueryParam();
        },
        onLoadError: function (err) {
            $.messager.progress("close");
            errorMsgAlert(err);
        }
    });

    /** DATAGRID 分页工具栏及分页查询 **/
    var pager = initd.dg.datagrid('getPager');
    $(pager).pagination({
        loading: true,
        beforePageText: '第',
        afterPageText: '页  共{pages}页',
        displayMsg: '显示条数{from}~{to},共{total}条记录',
        onSelectPage: function (pageNum, pageSize) {
            initd.dg.datagrid('loading');
            $.ajax({
                type: "POST",
                url: projectName + initd.queryDataURL,
                data: JSON.stringify({
                    'page': pageNum,
                    'rows': pageSize
                }),
                dataType: "json",
                contentType : "application/json;charset=utf-8",
                success: function (data) {
                    $.messager.progress("close");
                    if (!data.success) {
                        alert(data.message);
                        return;
                    }
                    if (data != null) {
                        console.log(data)
                        initd.dg.datagrid('loadData', data);
                        initd.dg.datagrid('loaded');
                    }
                },
                error: function (err, status) {
                    $.messager.progress("close");
                    initd.dg.datagrid('loaded');
                    errorMsgAlert(err);
                }
            });
        }
    });
</script>
</body>
</html>

